home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / GOFER / scripts / Grundy < prev    next >
Text File  |  1993-03-08  |  213b  |  11 lines

  1. --- Grundy numbers
  2.  
  3. data Game = Moves [Game]
  4.  
  5. grundy :: Game -> Int
  6. grundy (Moves gs) = least (\n -> and [n/=grundy g|g<-gs])
  7.  
  8. least p = x where x:_ = [ n | n <- [0 ..], p n ]
  9.  
  10. nim n = Moves [nim m|m<-[0..(n-1)]]
  11.